import { Layout, Login } from '@/components'

import { Route ,useHistory} from 'react-router-dom'
import { useAppSelector } from '@/hooks'

export default ()=> {
  const h = useHistory()
  const isLoign = useAppSelector(store=>store.user.token)
  if(!isLoign){
    h.push('/login')
}

  return (
    <>
      {
        isLoign
        ? <Route path='/' component={Layout} />
        : <Route path='/login' component={Login} />
      }
    </>
  )
}
